package com.forum.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.forum.dao.SystemintroDao;
import com.forum.entity.SystemintroEntity;
import com.forum.entity.view.SystemintroView;
import com.forum.service.SystemintroService;
import com.forum.utils.MyQuery;
import com.forum.utils.PageUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @ClassNameSystemintroService
 * @Author Lenovo
 * @Date 2023/11/25 16:21
 */
@Service
public class SystemintroServiceImpl extends ServiceImpl<SystemintroDao, SystemintroEntity> implements SystemintroService {

    @Override
    public List<SystemintroView> selectView(Wrapper<SystemintroEntity> wrapper) {
        return null;
    }

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        //调用Mybatis-plus的分页功能
        Page<SystemintroEntity> page = this.selectPage(
                //Mybatis-plus查询方法
                new MyQuery<SystemintroEntity>(params).getPage(),
                //entitywrapper方法是一个众所周知的方法，
                // 它是一个实体包装器，可以通过链式编程方式构建查询条件，
                // 从而方便地进行复杂的数据查询和操作
                new EntityWrapper<SystemintroEntity>()
        );
        return new PageUtils(page);
    }

    @Override
    public PageUtils queryPage(Map<String, Object> params, Wrapper<SystemintroEntity> wrapper) {
        Page<SystemintroView> page = new MyQuery<SystemintroView>(params).getPage();
        //调用mybatis-plus的baseMapper接口进行一个查询试图
        page.setRecords(baseMapper.selectListView(page, wrapper));
        PageUtils pageUtil = new PageUtils(page);
        return pageUtil;
    }


    @Override
    public List<SystemintroView> selectListView(Wrapper<SystemintroEntity> wrapper) {
        return baseMapper.selectListView(wrapper);
    }
}
